@use '@scss/common' as *;
@use '../shared.scss';

.select {
  position: relative;

  &::before {
    content: '';
    width: calc(100% - 2px);
    position: absolute;
    height: 100%;
    left: 1px;
    top: 0;
    z-index: -1;
  }

  .errorAndLabel {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    left: 2rem;
    display: flex;
    align-items: center;
    pointer-events: none;
    transition: all 0.3s ease;

    @include mid-break {
      left: 1rem;
    }
  }

  .selectLabel,
  .errorLabel {
    width: fit-content;
    margin: 0;
  }

  .selectLabel {
    transition: all 0.3s ease;
    pointer-events: none;
    font-weight: 400;
    margin-right: 0.75rem;
    z-index: 1;
  }
}

.reactSelect {
  display: flex;

  :global {
    div.rs__control {
      @include shared.formInput;
      & {
        padding: 1.5rem 2rem;
      }

      @include mid-break {
        padding: 1.5rem 1rem;
      }
    }

    .rs__control {
      line-height: 1;
      display: flex !important;
      align-items: center !important;

      &--is-disabled {
        cursor: not-allowed;

        :global {
          .rs__single-value {
            color: var(--theme-elevation-400);
          }

          .rs__indicators {
            display: none;
          }
        }
      }
    }

    .rs__input-container {
      color: var(--text-dark);
    }

    .rs__value-container {
      padding: 0;

      .rs__placeholder {
        display: none;
      }

      > * {
        margin-top: 0;
        margin-bottom: 0;
        padding-top: 0;
        padding-bottom: 0;
      }
    }

    .rs__single-value {
      color: var(--color-base-0);
      margin: 0;
      overflow: unset;
    }

    .rs__indicators {
      position: absolute;
      top: 50%;
      right: 2rem;
      transform: translate3d(0, -50%, 0);

      .arrow {
        transform: rotate(90deg);
      }

      @include mid-break {
        right: 1rem;
      }
    }

    .rs__indicator {
      padding: 0px 4px;

      svg path {
        fill: var(--theme-elevation-700);
      }

      &:hover {
        svg path {
          fill: var(--theme-elevation-700);
        }
      }
    }

    .rs__indicator-separator {
      display: none;
    }

    .rs__menu {
      color: var(--text-dark);
      background-color: #101010;
      z-index: 2;
      border-radius: 0;
      box-shadow: 0 4px 11px hsl(0deg 0% 0% / 10%);
      width: 100%;
      margin-top: 0;
      margin-bottom: 0;
    }

    .rs__menu-list {
      padding: 0;
      border: 1px solid var(--theme-border-color);
    }

    .rs__group-heading {
      margin-bottom: 0.5rem;
    }

    .rs__option {
      font-size: 1rem;
      padding: 1rem 2rem;
      background-color: #101010;

      &--is-focused {
        background-color: var(--color-base-900);
        color: var(--color-base-0);
      }

      &--is-selected {
        background-color: var(--color-base-800);
        color: var(--color-base-0);
      }

      @include mid-break {
        padding: 1rem 1rem;
      }
    }

    .rs__multi-value {
      padding: 0;
      background: var(--color-base-800);
    }

    .rs__multi-value__label {
      max-width: 150px;
      color: var(--color-base-0);
      padding: 0.125rem 0.25rem;
    }

    .rs__multi-value__remove {
      cursor: pointer;

      &:hover {
        color: var(--color-base-0);
        background: var(--color-base-900);
      }
    }

    .rs__clear-indicator {
      cursor: pointer;
    }
  }
}

.description {
  @include small;
  & {
    margin-top: 0.5rem;
  }
}

.focused {
  .errorAndLabel {
    top: 25%;
    transform: translateY(-25%);
  }

  .selectLabel,
  .errorLabel {
    font-size: 12px;
  }

  .selectLabel {
    margin-right: 0.5rem;
  }

  .reactSelect {
    :global {
      div.rs__control {
        padding: 2rem 2rem 1rem 2rem;

        @include mid-break {
          padding: 2rem 1rem 1rem 1rem;
        }
      }
    }
  }
}

:global([data-theme='dark']) {
  .select {
    .rs__menu {
      background-color: #101010;
    }
  }
}
